import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class cleanReads {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException 
	{
		String genesDataFolder = "/local1/projects2/UZH2/geneData/";
		String geneFile = "/local1/projects2/UZH2/gene_cluster.fna";
			BufferedReader bufferedReader = new BufferedReader(new FileReader(geneFile));
			String buffString = bufferedReader.readLine();
			FileWriter fileWriter = null;
			while(buffString != null)
			{
				if (buffString.startsWith(">"))
				{
					if (fileWriter != null)
					{
						fileWriter.flush();fileWriter.close();
					}
					fileWriter = new FileWriter(genesDataFolder + File.separator + buffString.substring(1).trim());
				}
				fileWriter.write(buffString + "\n");
				buffString = bufferedReader.readLine();
			}
			bufferedReader.close();
			fileWriter.flush();
			fileWriter.close();
//		Other
//		String workspace = "";
//		String scaffoldFileName = "";
//		String outputFile=  "";
//		String queryFile = "";
//		String genesDataFolder = "";
//		String database = "";
//		AntRequestHandler req = null;
//		File fl = new File(workspace);
//		String[] files = fl.list();
//		for (String file : files)
//		{
//			LinkedList<NameValuePair> newList = new LinkedList<NameValuePair>();
//			newList.add(new NameValuePair("formatdbDatabase",""));
//			newList.add(new NameValuePair("workingdir",genesDataFolder));	
//			newList.add(new NameValuePair(outputFile, FileUtilities.removeExtension(file) 
//					+ ".txt"));
//			newList.add(new NameValuePair("contigsFile", file));
//			newList.add(new NameValuePair("outputType","2"));
//			req = new AntRequestHandler();
//			req.runAnt(new File(""),newList,null);
//			System.out.println("hits file created at" + String.format("%s/%s", genesDataFolder, FileUtilities.removeExtension(file) 
//					+ ".txt"));
//		}
	}

}
